<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <div id="a">

    </div>
    <script>
        window.onload = function () {
            var num = 5
            var myTimer = setInterval(function () {
                num--
                if(num<0){
                    num=5
                }
                a.innerHTML=num
            }, 1000)
        }
    </script>
</body>
</html>